// matrix addition

# include <iostream>
using namespace std;

class MatrixAdder {
  int row, col, i, j;
  int a[10][10], b[10][10], c[10][10];
public:
  void get();
  void add();
  void display();
};

void MatrixAdder::get() {
  cout << "Enter rows for first and second matrix: ";
  cin >> row;
  cout << "Enter columns for first and second matrix: ";
  cin >> col;
  cout << "\n";
  for(i = 0; i < row; i++) {
    for(j = 0; j < col; j++) {
      cout << "Enter element [" << i+1 << ", " << j+1 << "] for matrix A: " ;
      cin >> a[i][j];
    }
  }
  cout << "\n";
  for(i = 0; i < row; i++) {
    for(j = 0; j < col; j++) {
      cout << "Enter element [" << i+1 << ", " << j+1 << "] for matrix B: " ;
      cin >> b[i][j];
    }
  }
}

void MatrixAdder::add() {
  for(i = 0; i < row; i++) {
    for(j = 0; j < col; j++) {
      c[i][j] = a[i][j] + b[i][j];
    }
  }
}

void MatrixAdder::display() {
  cout << "\nMatrix A:\n\n";
  for(i = 0; i < row; i++) {
    for(j = 0; j < col; j++) {
      cout << "\t" << a[i][j];
    }
    cout << "\n";
  }  
  cout << "Matrix B:\n\n";
  for(i = 0; i < row; i++) {
    for(j = 0; j < col; j++) {
      cout << "\t" << b[i][j];
    }
    cout << "\n";
  }  
  cout << "Matrix C:\n\n";
  for(i = 0; i < row; i++) {
    for(j = 0; j < col; j++) {
      cout << "\t" << c[i][j];
    }
    cout << "\n";
  }  
}

int main() {
  MatrixAdder ma;
  mm.get();
  mm.add();
  mm.display();
}
